﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Ylh.IDAL;
using Ylh.Model;
using Ylh.DBUtility;
using System.Data;
using System.Data.SqlClient;


namespace Ylh.SQLServerDAL
{
    public class PcSystemInfoDAL : IPcSystemInfo
    {
        /// <summary>
        /// 获取数据库中的当前程序的版本号
        /// </summary>
        /// <param name="ConStr"></param>
        /// <returns></returns>
        public string GetVersionCode(string ConStr)
        {
            string sql = @"SELECT [Version] FROM dbo.TbPcSystemInfo";
            DataTable dt = SqlHelper.ExcuteQuery(ConStr, sql, System.Data.CommandType.Text);
            return dt.Rows[0]["Version"].ToString();
        }


        /// <summary>
        /// 更新当前数据库的版本号码
        /// </summary>
        /// <param name="ConStr"></param>
        /// <param name="NewVersionCode"></param>
        /// <returns></returns>
        public bool UpdataVersionCode(string ConStr, string NewVersionCode)
        {
            string sql = @"update TbPcSystemInfo SET Version=@Version";

            SqlParameter[] pre = new SqlParameter[] 
            {
              new SqlParameter ("@Version",NewVersionCode)
             };

            int i = SqlHelper.ExecuteNonQuery(ConStr, sql, pre, System.Data.CommandType.Text);
            if (i > 0) return true;
            return false;
        }

    }
}
